class zuijiejin:
    def __init__(self,nums,target):
        self.nums=nums;
        self.a=target;
    def solution(self):
        dict={};
        list1=[];
        for i in range(0,len(self.nums)-2):
            for j in range(i+1,len(self.nums)-1):
                for k in range(j+1,len(self.nums)):
                    b=abs(int(self.a)-(self.nums[i]+self.nums[j]+self.nums[k]));
                    list=[self.nums[i],self.nums[j],self.nums[k]]
                    dict[b]=list;
        for key in dict:
            list1.append(key);
        print(dict[min(sorted(list1))]);

if __name__ == '__main__':
    nums=[];
    a=input("输入一串数据");
    target=input("输入一个目标值");
    for i in a.split(","):
        nums.append(int(i));
    b=zuijiejin(nums,target);
    b.solution();


